/**
 * electron 启动
 */
const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow

const path = require('path')
const url = require('url')

let mainWindow

var rundir = process.argv[2] || 'main.html'
function createWindow () {
  mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences:
      { nodeIntegration: true }
  })

  mainWindow.loadURL(url.format({
    pathname: path.join(__dirname, rundir),
    protocol: 'file:',
    slashes: true,
	}))
  mainWindow.on('closed', function () {
    // in an array if your app supports multi windows, this is the time
    mainWindow = null
  })
}

app.on('ready', createWindow)

app.on('window-all-closed', function () {
  if (process.platform !== 'darwin') {
    app.quit()
  }
})

app.on('activate', function () {
  if (mainWindow === null) {
    createWindow()
  }
})

// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
